package cn.xtits.xtf.common.utils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * Created by ShengHaiJiang on 2017/4/10.
 */
public class JsonUtil {

    public static final Logger logger = LoggerFactory.getLogger(JsonUtil.class);

    private static Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();


    public static <T> T fromJson(String json, Class<T> t) {
        if (StringUtils.isBlank(json)) {
            return null;
        }
        return gson.fromJson(json, t);
    }

    public static String toJson(Object obj)
    {
        return gson.toJson(obj);
    }
}
